import requests
import re

web_page_code = requests.get("https://www.sanchuangedu.cn/")

match_text = web_page_code.text #网页代码

reg = re.findall(r"(?<=src=\").+(?=\" alt)|(?<=url\().+(?=\);\">)",match_text)
# print(reg)
image_nums = len(reg)
print(f"一共{image_nums}张图片")

j = 0
for i in reg:
    pic = requests.get("https://www.sanchuangedu.cn/" + i)
    picture = pic.content #二进制代码 content是网页的二进制形式，要获取网页里的图片就可以通过这种方式
    j += 1

    with open(rf"E:\三创\笔记\2021.07.26\images\图{j}.jpg","wb+") as fp:
        fp.write(picture)
